<template>
	<view>
		<view class="uni-box">
			<uni-title class="h4" type="h4" title="基本信息"></uni-title>

			<uni-forms label-width="100px" label-align="center">
				<uni-forms-item v-for="(item,index) in _data.baseData" :key="index" :label="item.label">
					<view style="height: 100%; display: flex; align-items: center;"
						v-if="item.value !== 'originalStockQty' && item.value !== 'originalSplitStock'">
						{{ formData[item.value] }}
					</view>

					<view style="height: 100%; display: flex; align-items: center;"
						v-if="item.value === 'originalStockQty'">
						{{ formData[item.value] }}
						{{formData.packingUnit }}
					</view>

					<view style="height: 100%; display: flex; align-items: center;"
						v-if=" item.value === 'originalSplitStock'">
						{{ formData[item.value] }}
						{{formData.splitUnit }}
					</view>
				</uni-forms-item>

			</uni-forms>
		</view>
	</view>
</template>

<script setup>
	import {
		onLoad
	} from '@dcloudio/uni-app';
	import {
		getPostDetail
	} from "./request.js"
	import {
		reactive,
		ref
	} from "vue";

	const formData = ref({})

	const _data = reactive({
		baseData: [{
				label: "药品名称：",
				value: "name",
			},
			{
				label: "规格：",
				value: "specification",
			},
			{
				label: "供应商：",
				value: "supplierName",
			},
			{
				label: "账面库存：",
				value: "originalStockQty",
			},
			{
				label: "实际库存：",
				value: "stockQty",
			},
			{
				label: "批号：",
				value: "batchNumber",
			},
			{
				label: "失效日期：",
				value: "endDate",
			},
			{
				label: "盈亏数量：",
				value: "changeStockQty",
			},
			{
				label: "成本盈亏：",
				value: "amount",
			}
		],

	})


	onLoad((e) => {
		console.log(e);
		formData.value = JSON.parse(e.id)
		// getPostDetail({
		// 	id: detailId
		// }).then((res) => {
		// 	formData.value = res.data.bodys[0]
		// })
	})
</script>

<style lang="scss">
	.uni-box {
		padding-left: 14rpx;
	}

	.uni-forms-item {
		border-bottom: 1rpx solid #ccc;
		margin-bottom: 0;
		padding-bottom: 12rpx;
	}
</style>